BEGIN
	EXEC qa_drop_table FileSetFile
END 

CREATE TABLE [dbo].[FileSetFile](
	[FileSetID] [bigint] NOT NULL,
	[FileID] [bigint] NOT NULL,
	[Position] [int] NULL,
 CONSTRAINT [PK_FileSetFile] PRIMARY KEY CLUSTERED 
(
	[FileSetID] ASC,
	[FileID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
 CONSTRAINT [UK_FileSetFile] UNIQUE NONCLUSTERED 
(
	[FileSetID] ASC,
	[FileID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[FileSetFile]  WITH CHECK ADD  CONSTRAINT [FK_FileSetFile_FileDefinition] FOREIGN KEY([FileID])
REFERENCES [dbo].[FileDefinition] ([FileID])
GO

ALTER TABLE [dbo].[FileSetFile] CHECK CONSTRAINT [FK_FileSetFile_FileDefinition]
GO

ALTER TABLE [dbo].[FileSetFile]  WITH CHECK ADD  CONSTRAINT [FK_FileSetFile_FileSet] FOREIGN KEY([FileSetID])
REFERENCES [dbo].[FileSet] ([FileSetID])
GO

ALTER TABLE [dbo].[FileSetFile] CHECK CONSTRAINT [FK_FileSetFile_FileSet]
GO

